#define  _CRT_SECURE_NO_WARNINGS
class Solution {
public:
    int getMaxLen(vector<int>& nums) {
        int n = nums.size();
        vector<int> f(n + 1), g(n + 1);
        int ret = 0;
        for (int i = 1; i <= n; i++)
        {
            int cur = nums[i - 1];
            if (cur < 0)
            {
                g[i] = 1 + f[i - 1];
                f[i] = g[i - 1] ? 1 + g[i - 1] : 0;
            }
            else if (cur > 0)
            {
                g[i] = g[i - 1] ? 1 + g[i - 1] : 0;
                f[i] = 1 + f[i - 1];
            }
            ret = max(ret, f[i]);
        }
        return ret;
    }
};